<template>
  <div class="product-list">
    <div
      v-for="item in list"
      :key="item.id"
      class="product-item"
    >
      <dl>
        <dt>
          <img :src="item.cover" />
        </dt>
        <dd>
          <div class="info">
            <h2>{{item.title}}</h2>
            <p>
              累计销售{{item.volume}}份
              <span>/</span>
              剩余库存{{item.count}}份
            </p>
            <button @click.stop="add(item)">添加购物车</button>

          </div>
          <div class="bottom">
            <span class="price">¥<b>{{item.price}}</b></span>
            <s class="oldPrice">¥{{item.oldPrice}}</s>
          </div>
        </dd>
      </dl>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ProductList',
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    add (item) {
      this.$store.dispatch('car/add', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.product-list {
  background: #fff;
  .product-item {
    @include wh(100%, auto);
    @include border1px(bottom, #E2E2E2);
    padding-left: 20px;
    dl {
      @include flex(row, initial, initial);
      dt {
        @include wh(240px, 240px);
        // margin-right: 30px;
        img {
          @include wh(240px, 240px);
        }
      }
      dd {
        @include flex(column, space-between);
        padding: 30px;
        flex: 1;
        .info {
          h2 {
            @include ellipsisLn(2);
            font-size: 32px;
            max-height: 104px;
            line-height: 1.2;
          }
          p {
            font-size:24px;
            color: #999999;
            margin-top: 12px;
            span {
              margin: 0 10px;
            }
          }
        }
        .bottom {
          s {
            font-size: 24px;
            color: #999999;
          }
          span {
            font-size: 24px;
            color: #999999;
            b {
              font-size: 36px;
            }
            &.price {
              color: $base-color;
              margin-right: 10px;
            }
          }
        }
      }
    }
  }
}
</style>
